#ifndef POINTCLOUDRENDERER_H
#define POINTCLOUDRENDERER_H

#include <QVector3D>
#include <QVector>

#include <qrender/renderer.h>

class QOpenGLShaderProgram;
class QOpenGLVertexArrayObject;
class QOpenGLBuffer;

class PointCloudRenderer : public Renderer
{
public:
    PointCloudRenderer();
    ~PointCloudRenderer();

    void setPoints(const QVector<QVector3D> &points,
                   QVector3D color = { 0.0, 1.0, 0.0 }, float point_size = 3.0);

protected:
    void create() override;
    void render(const CameraInfo &camera) override;
    void release() override;

private:
    QVector3D color_{ 0.0, 1.0, 0.0 };
    float point_size_{ 3.0 };
    bool data_changed_{ true };

    std::shared_ptr<QOpenGLShaderProgram> program_{ nullptr };
    std::shared_ptr<QOpenGLVertexArrayObject> vao_{ nullptr };
    std::shared_ptr<QOpenGLBuffer> vbo_{ nullptr };

    QVector<QVector3D> points_; ///< 顶点数据, 点云
};

#endif // POINTCLOUDRENDERER_H
